package com.itheima.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo03 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable my = new MyCallable();
        FutureTask<String> task = new FutureTask<>(my);
        Thread t = new Thread(task);
        t.start();


        for (int i = 0; i < 100; i++) {
            System.out.println("main线程执行到了"+i);
        }

        String s = task.get();
        System.out.println(s);
    }
}

class  MyCallable implements Callable<String>{


    @Override
    public String call() throws Exception {
        for (int i = 0; i < 100; i++) {
            System.out.println("myCallable执行到了"+i);
        }
        return "哈哈哈";
    }
}
